from django.db import models
from django.contrib.auth import get_user_model
from django.contrib.auth.models import AbstractUser
from rest_framework.authtoken.models import Token
from django.conf import settings

class UserModel(AbstractUser):
    created_at = models.DateTimeField(
        auto_now_add=True,
        editable=False,
        null=True,
        help_text="创建时间"
    )
    updated_at = models.DateTimeField(
        auto_now=True,
        editable=False,
        null=True,
        help_text="更新时间"
    )
    
    groups = models.ManyToManyField(
        'auth.Group',
        verbose_name='groups',
        blank=True,
        help_text='The groups this user belongs to.',
        related_name='usermodel_set',
        related_query_name='usermodel',
    )
    user_permissions = models.ManyToManyField(
        'auth.Permission',
        verbose_name='user permissions',
        blank=True,
        help_text='Specific permissions for this user.',
        related_name='usermodel_set',
        related_query_name='usermodel',
    )
    session_key = models.CharField(max_length=256, default=None, null=True)

    class Meta:
        db_table = "user"
        ordering = ["-date_joined"]
        verbose_name = "用户"
        verbose_name_plural = "用户"

    def __str__(self):
        return self.username